require(['./config'],()=>{
    //引用config 中的配置的header
    require(['swiper','template','request','header','nav','footer','jquery'],(Swiper,temp,req)=>{
         class Index{
            constructor(){
                this.initSwiper()
                this.getRecomData()
                // this.getSugarPeiJ()
                // this.test()
            }
            // 初始化轮播图
            initSwiper(){
                new Swiper('.swiper-container', {
                    cssMode: true,
                    navigation: {
                      nextEl: '.swiper-button-next',
                      prevEl: '.swiper-button-prev',
                    },
                    pagination: {
                      el: '.swiper-pagination'
                    },
                    mousewheel: true,
                    keyboard: true,
                  })
            }
            //获取人气推荐数据
            getRecomData(){
             req.getIndex1()
                .then(res => {
                    // console.log(res)
                    if(res.code === 1){
                        // 渲染页面 code===1表示成功获取数据
                        this.renderData(res.result_body)
                    }
                })

            }
            //渲染页面
            renderData(res){
              // console.log(res)
               const html=temp('templateRecom',{list:res})
              //  console.log(html)
              //然后把html放入父元素中
              $('.shopwrap ul').html(html)
                 
            }
         }
         return new Index()
    })

})